package com.jiot.controller.user;

import com.zg.cloud.BaseResponse;
import com.zg.cloud.annotation.TokenCheck;
import com.zg.cloud.service.UserTimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import req.user.AddUserTimeReq;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author hushi
 * @date 2020/11/4 16:42
 * @description
 */
@RestController
@RequestMapping("/user/time")
@Api(value = "记录用户第一次操作时间")
public class UserTimeController {

    @Resource
    private UserTimeService userTimeService;

    @PostMapping("/add/user/time")
    @TokenCheck
    @ApiOperation(value = "添加用户操作时间", notes = "user")
    public BaseResponse addUserTime(@RequestBody @Valid AddUserTimeReq addUserTimeReq) {
        userTimeService.addUserTime(addUserTimeReq);
        return new BaseResponse();
    }

    @TokenCheck
    @PostMapping("/user/device/time")
    @ApiOperation(value = "用户添加设备时间", notes = "user")
    public BaseResponse userDeviceTime() {
        return new BaseResponse(userTimeService.userDeviceTime());
    }
}
